<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;
/*自动下课记录*/
class AutoLessonend extends AdminBase{
	protected $beforeActionList = [
        'before_index'=>['only'=>'index'],
    ];
	function _initialize() {
    		parent::_initialize();
    }
	/*门店列表*/
	function index(){
		echo $this->fetch();
	}
	function sign(){
		$model=db("AutoLessonEnd")->find(input('id'));
		$this->assign("model",$model);
		echo $this->fetch();
	}
	function sign_post(){
		if(request()->isPost()){//提交
		    db("AutoLessonEnd")->where("id=".input("id"))->setField(array("sign_status"=>input("sign_status"),"sign_descs"=>input("sign_descs")));
			$this->ajax_success("成功");
		}
	}
	
	function ajax_index(){
		$this->ajax($this->_ajax_index());
	}
	
	///////////////////////////////////////////////////////////////////////////////////
	/**
	 * 权限菜单
	 **/
	function before_index(){
		$auth_group=sp_get_auth_menu_3("10041028");
		$this->assign("menus",$auth_group);
	}
	private function _ajax_index(){
		$query=array(
		 'employee_name'=>array("field" =>"employee_name","operator" =>"="),
		 'member_name'=>array("field" =>"member_name","operator" =>"="),
		 'reservation_name'=>array("field" =>"reservation_name","operator" =>"="),
		 'result_status'=>array("field" =>"result_status","operator" =>"="),
		 'start_status'=>array("field" =>"start_status","operator" =>"="),
		 'sign_status'=>array("field" =>"sign_status","operator" =>"="),
		);
		$shop_id=sp_get_current_shop_id();
		$draw=input("draw",0)+1;//请求时间		 
		$where_and=join(" and ",sp_get_param_sql(request()->isPost(),$query));
		$where_and.=" and shop_id=$shop_id";
		$total=db("AutoLessonEnd")->where($where_and)->count(1);
		$list=db("AutoLessonEnd")->where($where_and)->order($this->get_order())->limit($this->get_limit())->fetchsql(FALSE)->select();
		return array('pageData'=>$list,'total'=>$total,"draw"=>$draw);
	}
}
